
const {   
    Program,
    AnchorProvider,
    BN,
    web3,
    Wallet,
} = require("@coral-xyz/anchor");


const {  
    Connection,
    clusterApiUrl,
    PublicKey,
    Keypair
} = require('@solana/web3.js')

const opts = {
    preflightCommitment: "recent",
  };
class BaseProgram{
    constructor(connection, wallet,idl, _programID){
        this.connection = connection;
        this.provider = new AnchorProvider(
            this.connection, wallet, opts.preflightCommitment,
          )
        const programID = new PublicKey(_programID);
        this.program = new Program(idl, programID, this.provider);
    }
    async methodsInstruction(methodsName, paras, accounts){
        return await this.program.methods[methodsName](paras).accounts(accounts).instruction();
    }

}

module.exports = BaseProgram;